<?php
class baoanModel extends model{
    public function __construct(){
		parent::__construct();
		$this->p = $this->app->loadClass('proving');
	}

	//数据插入
	public function insert_data($data){
		//a($data);exit;
		foreach($data as $v){
			$this->dao->insert('print_papers')
				->set('name')->eq($v->name)
				->set('sfz')->eq($v->sfz)
				->set('papers')->eq($v->papers)
				->set('address')->eq($v->address)
				->set('fadate')->eq($v->fadate)
				->set('crtime')->eq($v->crtime)
				->exec();
		}

	}
	//获取未打印的保安员列表 列表
	public function get_list($where){
	    $data= $this->dao->select('*')
	    			->from('print_papers')
	    			->where("$where")
	    			->orderby('id asc')
	    			->fetchALL();
		return $data;
	}

	//获取单个的保安人员  打印信息
	public function user_data($where){
	     $data= $this->dao->select('*')->from('print_papers')->where($where)->fetch();
		return $data;
	}

	//更新为已打印
	public function user_update($id){
		$uptime = date('Y-m-d H:i:s', time()) ;	//添加时间
		$res = $this->dao->update('print_papers')
							 ->set('status')->eq('1')
							 ->set('uptime')->eq($uptime)
							 ->where('id')->eq($id)
							 ->exec();
                             //printSQL();
	}
   //更新信息
	public function up_editor($where,$id){
		return $res = $this->dao->update('print_papers')
							 ->set("$where")
							 ->where('id')->eq($id)
							 ->exec();
	}
    //总条数
	public function applyCount($where){
		$num = $this->dao->select('count(*) as n')
	    			->from('print_papers')
	    			->where("$where")
	    			->orderby('id asc')
	    			->fetch();

		return $num->n;
	}
	//删除
	public function user_deluser($id){
		return $res = $this->dao->update('print_papers')
							 ->set('status')->eq('3')
							 ->where('id')->eq("$id")
							 ->exec();
							//->printSQL();
	}
}
